home *** CD-ROM | disk | FTP | other *** search
- /* This app is just a shell, so we can test the MenuSelect code more easily
-
- */
-
-
- #include <QDOffscreen.h>
- #include <string.h>
-
- #include "MenuSelect.h"
-
- OSErr DoMenu(long menuCode);
- OSErr DoMouseDown(EventRecord* theEvent);
- void main(void);
- OSErr DoEvent(EventRecord* theEvent);
- OSErr SetupMenus(void);
-
-
- static void InitToolbox(void)
- {
-
- MaxApplZone();
- MoreMasters();
- MoreMasters();
-
- /* Initialize the various Managers */
- InitGraf(&qd.thePort);
- InitFonts();
- FlushEvents(everyEvent, 0);
- InitWindows();
- InitDialogs(nil);
- }
-
-
- void main(void)
- {
- EventRecord theEvent;
-
- InitToolbox();
-
- SetupMenus();
- DrawMenuBar();
-
- while(1)
- {
- WaitNextEvent(everyEvent, &theEvent, 0, nil);
- DoEvent(&theEvent);
- }
- }
-
-
- OSErr SetupMenus(void)
- {
- MenuHandle appleMenu = nil;
-
- SetMenuBar(GetNewMBar(128));
-
- AddResMenu(GetMenuHandle(1), 'DRVR');
-
- }
-
-
- OSErr DoEvent(EventRecord* theEvent)
- {
- switch(theEvent->what)
- {
- case mouseDown:
- return DoMouseDown(theEvent);
- break;
- }
- }
-
- OSErr DoMouseDown(EventRecord* theEvent)
- {
- OSErr result = noErr;
- WindowPtr w = nil;
- short theType = FindWindow(theEvent->where, &w);
- long menuResult = 0;
-
- switch(theType)
- {
- case inMenuBar:
- menuResult = AltMenuSelect(theEvent->where, kFXSlide, kFXZoomIn);
-
- if (menuResult)
- result = DoMenu(menuResult);
- break;
- default:
- ExitToShell();
- break;
- }
-
- return result;
- }
-
- enum {kAppleMenuID = 1, kFileMenuID, kEditMenuID};
-
- OSErr DoMenu(long menuCode)
- {
- short menuID = menuCode >> 16;
- short menuItem = menuCode & 0xFF;
- OSErr result = noErr;
-
- switch(menuID)
- {
- case kAppleMenuID:
-
- break;
-
- case kFileMenuID:
- ExitToShell();
- break;
- }
-
- return result;
- }
-
-
-